package com.api.department.getdepartment;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IDepartmentApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.DepartmentApi;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(locations = "classpath:/department/departments-toget.xml")
public class GetDepartment extends AbstractApiTest {

	@Value("#{user_contact.appId}")
	private String userUrn;

	@Value("#{user_contact.password}")
	private String userPassword;

	@Value("#{department_toGet.urn}")
	private String iddepartment;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void test() throws ZyncroApiException {
		ObjectResultApi<DepartmentApi> result = getApi().getService(IDepartmentApiService.class).getDepartment(iddepartment);

		Assert.assertEquals(result.getObject().getUrn(), iddepartment, "Department urn");
	}
}
